// notes-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.

module.exports = function (app) {
  const mongooseClient = app.get('mongooseClient')
  const { Schema } = mongooseClient
  const dbname = 'notes'
  const notes = new Schema({
    title: { type: String, required: true },
    md: { type: String, required: true }
  }, {
    timestamps: true
  })
  if (mongooseClient.models[dbname]) delete mongooseClient.models[dbname]
  return mongooseClient.model(dbname, notes)
}
